<?php
class MaestroHelper extends AppHelper {
	var $helpers = array('Html');
	
	public function showTreeMenus($menus = null) {
		$out = array();
		if($menus !== null) {
			
		}
		
		$out = '';
		$lists = Configure::read('Menus');
		$out .= $this->recursiveList($lists, 0);
		return $this->output($out);
	}
	
	private function recursiveList($lists, $depth) {
		$class = ($depth++==1)? '' : ' class="sf-menu"';
		$out = '';
		$out .= '<ul'.$class.'>';
		foreach($lists as $list) {
			$out .= '<li>';
			$out .= empty($list['url'])? $list['title'] : $this->Html->link($list['title'], $list['url']);
			if(!empty($list['children']))
				$out .= $this->recursiveList($list['children'], $depth);
			$out .= '</li>';
		}
		$out .= '</ul>';
		$depth--;
		return $out;
	}
}
?>